import typescript from "@rollup/plugin-typescript";
import pkg from "./package.json";
import json from "@rollup/plugin-json";
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { string } from 'rollup-plugin-string';
import dts from "rollup-plugin-dts";

const defaultNamespace = 't';

export default [
  {
    input: "index.ts",
    plugins: [
      json(),
      nodeResolve(),
      string({
        include: [
          '**/*.frag',
          '**/*.vert',
        ],
      }),
      typescript({
        tsconfig: "./tsconfig.json"
      }),
    ],
    output: [
      {
        file: pkg.main,
        format: "cjs",
        sourcemap: true
      },
      {
        file: pkg.module,
        format: "esm",
        sourcemap: true
      },
      {
        file: pkg.bundle,
        format: "umd",
        sourcemap: true,
        name: pkg.namespace || defaultNamespace
      }
    ],
  },
  {
    input: "./index.ts",
    output: [{
      file: "dist/index.d.ts",
      format: "umd",
      name: pkg.namespace || defaultNamespace
    }],
    plugins: [
      dts({ respectExternal: true })
    ],
  },
];
